/*
 *  Copyright (c) 1998-2001, The University of Sheffield.
 *
 *  This file is part of GATE (see http://gate.ac.uk/), and is free
 *  software, licenced under the GNU Library General Public License,
 *  Version 2, June 1991 (in the distribution as file licence.html,
 *  and also available at http://gate.ac.uk/gate/licence.html).
 *
 *  TheFinder.java
 *
 *  Valentin Tablan, 27-Apr-2006
 *
 *  $Id$
 */

package gatecourse;

import gate.*;
import gate.creole.*;
import gate.util.*;

public class TheFinder extends AbstractLanguageAnalyser{
  
  private String annotationSetName;
  public String getAnnotationSetName() {
    return annotationSetName;
  }
  public void setAnnotationSetName(String annotationSetName) {
    this.annotationSetName = annotationSetName;
  }
  public void execute() throws ExecutionException {
    String text = document.getContent().toString();
    int index = 0;
    while(index != -1){
      index = text.indexOf("the", index + 1);
      if(index != -1){
        FeatureMap features = Factory.newFeatureMap();
        try{
          document.getAnnotations().add(new Long(index), new Long(index + 3), 
                  "The", features);
        }catch(Exception e){
          throw new GateRuntimeException(e);
        }
      }
    }
  }
}
